thin.imports('/public/configure/conf.complete.js');

$(function() {
	$('#btn-cy').on('click', function(e) {
		data_role = 1;
		checkLocation('pass');
	});

	$('#btn-viden').on('click', function() {
		$.modal({
			title: "您是？",
			text: "",
			buttons: [{
					text: "个人天使",
					onClick: function() {
						data_role = 2;
						checkLocation('pass');
					}
				},
				{
					text: "机构投资人",
					onClick: function() {
						data_role = 3;
						checkLocation('mechanism');
					}
				}
			]
		});
	});

	$('#btn-register').on('click', function(e) {
		wxregister();
	});
});

var data_role = null;
var __getdata_wxreg = {};

function wxregister() {
	var data = {
		'mobile': $('[name=mobile]').val(),
		'role': data_role,
		'organization': $('#ipt-jgname').val(),
		'password': $('[name=password]').val(),
		'confpwd': $('[name=confpwd]').val(),
	};
	if(data.password == '') {
		$.toptip('请输入密码', 'error');
		return;
	} else if(data.confpwd == '') {
		$.toptip('请再次输入密码', 'error');
		return;
	}
	$.showLoading();
	__getdata_wxreg = data;
	factory.request('_reg_wxreg');
}

function __complete_wxreg(res) {
	$.hideLoading();
	if(res.status == 201) {
		$.toast("注册成功", 960);
		setTimeout(function() {
			checkLocation('memberinfo');
		}, 800);
	} else {
		$.toptip(res.error, 'error');
	}
}